﻿
//新增
var fnCustomAdd = function () {
    document.getElementById("EditUIWindow").src = "AutoEditUI.aspx?r=" + Math.random() + "&entity=" + const_EditEntity;
    YAHOO.example.container.dialog1.show();
    document.getElementById("yui-gen17-button").style.display = "block"; 
}
//编辑
var fnCustomEdit = function () {
    document.getElementById("EditUIWindow").src = "AutoEditUI.aspx?r=" + Math.random() + "&entity=" + const_EditEntity + "&id=" + record.getData(const_entityID);
    YAHOO.example.container.dialog1.show();
    document.getElementById("yui-gen17-button").style.display = "block"; 
}

//问卷题目
var fnTrQuestionnaireSubject = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    var items = record.getData("SubjectSum");
//    var startTime = record.getData("QStartTime");
//    var myDate = new Date();
//    var year = myDate.getYear();
//    var month = myDate.getMonth() + 1;
//    var date = myDate.getDate();
//    if (month < 10) {
//        month = "0" + month;
//    }
//    if (date < 10) {
//        date = "0" + date;
//    }
//    var day = year + "-" + month + "-" + date;
//    var sday = startTime.replace(" ", "");
//    if (day <= sday) {
//        document.getElementById("EditUIWindow3").src = "../TR/SubjectList.aspx?r=" + Math.random() + "&entity=V_TrQuestionnaireSubject&id=" + record.getData(const_entityID) + "&its=" + items + "";
//        YAHOO.example.container.dialog5.show();
//    } else {
//        alert("问卷已开始，不能选择题目");
    //    }
    document.getElementById("EditUIWindow3").src = "../TR/SubjectList.aspx?r=" + Math.random() + "&entity=V_TrQuestionnaireSubject&id=" + record.getData(const_entityID) + "&its=" + items + "";
    YAHOO.example.container.dialog5.show();
    document.getElementById("yui-gen17-button").style.display = "block"; 
}

//问卷发送
var fnSendTrQuestionnaire = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
//    var startTime = record.getData("QStartTime");
//    var endTime = record.getData("QEndTime");
//    var myDate = new Date();
//    var year = myDate.getYear();
//    var month = myDate.getMonth() + 1;
//    var date = myDate.getDate();
//    if (month < 10) {
//        month = "0" + month;
//    }
//    if (date < 10) {
//        date = "0" + date;
//    }
//    var day = year + "-" + month + "-" + date;
//    var sday = startTime.replace(" ", "");
//    if (day <= sday) {
//        document.getElementById("EditUIWindow").src = "../TR/QuestionnaireSend.aspx?r=" + Math.random() + "&entity=" + const_EditEntity + "&id=" + record.getData(const_entityID);
//        YAHOO.example.container.dialog1.show();
//    } else {
//        alert("问卷已开始，不能发送问卷");
    //    }
    document.getElementById("EditUIWindow").src = "../TR/QuestionnaireSend.aspx?r=" + Math.random() + "&entity=" + const_EditEntity + "&id=" + record.getData(const_entityID);
    YAHOO.example.container.dialog1.show();
    document.getElementById("yui-gen17-button").style.display = "block";
}


//问卷总结
var fnTrQuestionnaireSumup = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
//    var startTime = record.getData("QStartTime");
//    var endTime = record.getData("QEndTime");
//    var myDate = new Date();
//    var year = myDate.getYear();
//    var month = myDate.getMonth() + 1;
//    var date = myDate.getDate();
//    if (month < 10) {
//        month = "0" + month;
//    }
//    if (date < 10) {
//        date = "0" + date;
//    }
//    var day = year + "-" + month + "-" + date;
//    var sday = startTime.replace(" ", "");
//    if (day >= sday) {
//        document.getElementById("EditUIWindow").src = "../TR/QuestionnaireSumup.aspx?r=" + Math.random() + "&entity=" + const_EditEntity + "&id=" + record.getData(const_entityID);
//        YAHOO.example.container.dialog1.show();
//    } else {
//        alert("问卷未开始，不能总结");
    //    }
    document.getElementById("EditUIWindow").src = "../TR/QuestionnaireSumup.aspx?r=" + Math.random() + "&entity=" + const_EditEntity + "&id=" + record.getData(const_entityID);
    YAHOO.example.container.dialog1.show();
    document.getElementById("yui-gen17-button").style.display = "block";
}

//问卷查看
var fnTrQuestionnaireCheck = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    document.getElementById("EditUIWindow3").src = "../TR/SubjectList.aspx?r=" + Math.random() + "&entity=V_TrSendQuestion&id=" + record.getData(const_entityID);
    YAHOO.example.container.dialog5.show();
    document.getElementById("yui-gen17-button").style.display = "block"; 
}

//问卷统计
var fnTrQuestionTj = function () {
    //alert("维护中...");
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    document.getElementById("EditUIWindow3").src = "../TR/QuestionnaireStatistics.aspx?r=" + Math.random() + "&id=" + record.getData(const_entityID);
    YAHOO.example.container.dialog5.show();
    document.getElementById("yui-gen17-button").style.display = "block";
}